libxl: consistent handling of libxc errors
authorGianni Tedesco <gianni.tedesco@citrix.com>
Fri, 23 Jul 2010 16:26:28 +0000 (17:26 +0100)
committerGianni Tedesco <gianni.tedesco@citrix.com>
Fri, 23 Jul 2010 16:26:28 +0000 (17:26 +0100)
commit2bdc928237ca74c5194d9487c21290eb8f1016c3
treeaf6fde7c555036b3b11f913926b76a3cc2e0c903
parentb545cf4fb2f9246b4dd50353e8018c2d66b9b3f7
libxl: consistent handling of libxc errors

Lots of places in libxl return -1 as an error which is inconsistent with
libxl error codes since that is ERROR_VERSION.  Also in other places the
xc_* function to implement a command is called but the return value is
either never checked or not passed on.

This patch makes callers of libxc functions use XL_LOG_ERRNO to log a
suitable message including the contents of errno, before returning
ERROR_FAIL, if an xc call fails.  (Except for pci device removals and
domain destroys where release of resources ought to continue even if
an error occurs in an early step. In this case the error is still
logged at least.)

Also a bug is fixed where a caller depends on errno being set but is
cleared by cleanup code which calls in to library functions which modify
errno as a side-effect.

This is version 2 of the patch previously applied as 91c486918e02.
Changed since then: Removed mapping from libxc error codes to libxl -
this is redundant because libxl ought to return -1 with errno set to a
meaningful value.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.h